package com.dailycodebuffer.springbootmongodb.controller;


import com.dailycodebuffer.springbootmongodb.collection.Shipper;
import com.dailycodebuffer.springbootmongodb.service.ShipperService;
import lombok.AllArgsConstructor;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;


/**
 * 控制层
 *
 * @author makejava
 * @since 2025-01-04 00:23:42
 */
@RestController
@RequestMapping("/shipper")
@AllArgsConstructor
public class ShipperController {

	private ShipperService shipperService;

	/**
	 * 获取列表(分页)
	 */
	@GetMapping("/list")
	public Page<Shipper> list(Pageable page) {
		return shipperService.list(page);
	}

	/**
	 * 获取
	 */
	@GetMapping("{id}")
	public Shipper get(@PathVariable("id") Integer id) {
		return shipperService.findById(id);
	}

	/**
	 * 添加
	 */
	@PostMapping("/add")
	public void add(@RequestBody Shipper shipper) {
		shipperService.save(shipper);
	}

}

